<template>
	<view class="tCenter w100">
		<view class="tCenter" v-if="showtext">
		<view class="tCenter">
			<img class="w20" src="../../static/img/news.png" ></img>
		</view>
		
		<view class="f16">{{showtext}}</view>
		</view>
		<backhome></backhome>
		<!-- 加载动画 -->
		<loading v-if="!isloading()"></loading>
	</view>
</template>

<script>
	import {arriveararrived,arrivearrived_code,appointmentadd_post} from '@/common/api/appointment.js'; //引进requst方法
	import {userinfo}  from '@/common/api/user.js'
	import backhome from '@/components/backhome.vue';
	export default {
		components: {
			backhome
		},
		data() {
			return {
				companyid:"",
				showtext:"",
				detaildata:[],
				id:"",
				departname:"",
			};
		},
		methods: {
			shodata(){
				
				let userid=uni.getStorageSync('userid');
				// appointmentadd_post({companyid:this.companyid,uid:userid}).then(res=>{
				// 	console.log(res)
				// })
				arriveararrived({companyid:this.companyid}).then(res=>{
					if(res.data.code=='200'){
						this.showtext='已通知门卫，请等待';
					}else{
						this.showtext=res.data.message;
					}
				})
				// 到达部门接口
				// arrivearrived_code({uid:userid,companyid:this.companyid}).then(res=>{
				// 	console.log(res)
					
				// })
				
			},
		},
		onLoad(event) {
			if(!this.isloading()){
				return
			}	
			// return
			this.companyid=event.companyid;
			userinfo({}).then(res=>{
				if(res.data.code == 200){
					uni.setStorage({
						key: 'userInfo',
						data: res.data.data
					});
					console.log(res)
					if(res.data.data.roleid == 5 || res.data.data.roleid === 6){
						uni.redirectTo({
							url:'../yuyuejilu/visterlist?companyid='+this.companyid
						})
						return 
					}
				}

			})
			this.shodata()
			
			// try {
			// 	this.detaildata = JSON.parse(decodeURIComponent(event.detailDate));
			// 	console.log(this.detaildata);
			// } catch (error) {
			// 	this.detaildata = JSON.parse(event.detailDate);
			// 	console.log(this.detaildata);
			// }
			// this.id = this.detaildata.deptid;
			// this.departname=this.detaildata.departname;			
		},
	}
</script>

<style>

</style>
